package main

import (
	"fmt"
)

func main() {
	var ch1 = make(chan int, 20)
	fmt.Printf("%T\n", ch1)
	for i := 0; i < 20; i++ {
		ch1 <- i
	}
	//close(ch1) //关闭管道
	//
	//for val := range ch1 {
	//	fmt.Printf("%d\n", val)
	//}
	fmt.Println("-----------------------------------------------")
	// for遍历管道不用关闭管道
	for i := 0; i < len(ch1); i++ {
		fmt.Printf("%d\n", <-ch1)
	}
}
